using UnityEngine;

namespace PKGames.AssetBundleSystem
{
	public class AssetBundleRef
	{
		private AssetBundle _assetBundle;

		private int _referenceCount;

		public AssetBundle AssetBundle => _assetBundle;

		public AssetBundleRef(AssetBundle assetBundle)
		{
			_assetBundle = assetBundle;
			_referenceCount++;
		}

		public int AddReference()
		{
			return ++_referenceCount;
		}

		public int RemoveReference()
		{
			return --_referenceCount;
		}

		public bool ShouldUnload()
		{
			return _referenceCount <= 0;
		}
	}
}
